#include "cDateTime_t.h"

cDateTime_t::cDateTime_t() : cDate_t(), cTime_t() {}

cDateTime_t operator+ (const cDateTime_t& time1, const cTime_t& time2) {
	struct tm tm_Temp;
	time1.fillStruct_tm(tm_Temp);
	time_t time_t_Temp = mktime(&tm_Temp);
	time_t_Temp = time_t_Temp + time2.getHour()*3600 + time2.getMinutes()*60 + time2.getSeconds();
	time_t_Temp = time_t_Temp + time1.getHour()*3600 + time1.getMinutes()*60 + time1.getSeconds();
	struct tm * t = localtime(&time_t_Temp);
	return cDateTime_t(t->tm_mday, t->tm_mon+1, t->tm_year + 1900, t->tm_hour, t->tm_min, t->tm_sec);
}


cDateTime_t &cDateTime_t::operator=(const cDateTime_t &other)
{
	if (this != &other)
	{
		_day = other.getDay();
		_month = other.getMonth();
		_year = other.getYear();
		_hour = other.getHour();
		_minute = other.getMinutes();
		_seconds = other.getSeconds();
	}
	return *this;
}


cDateTime_t operator+ (const cTime_t& time2, const cDateTime_t& time1) {
	return time1 + time2;
}

cDateTime_t::cDateTime_t(const int& day, const int& month, const int& year, const int &hour, const int &min, const int &sec) : cDate_t(day, month, year), cTime_t(hour, min, sec) {}

cDateTime_t::cDateTime_t(const cDateTime_t& mycTime)
{
	_minute = mycTime.getMinutes();
	_hour = mycTime.getHour();
	_seconds = mycTime.getSeconds();
	_year = mycTime.getYear();
	_month = mycTime.getMonth();
	_day = mycTime.getYear();
	cDate_t::_printFormat = ((cTime_t)mycTime).getPrintFormat();
	cDate_t::_printFormat = ((cDate_t)mycTime).getPrintFormat();
}



ostream &operator<<(ostream&  os, const cDateTime_t &t)
{
	return os << (cDate_t)t << "\t" << (cTime_t)t;
}